<div xmlns:th="http://www.thymeleaf.org" class="layui-header layui-bg-blue" th:fragment="header(index)">
    <div class="layui-logo lxb-logo">My Forum</div>
    <!-- 头部导航栏 -->
    <ul class="layui-nav layui-layout-left">
        <li th:class="${index == 0 ? 'layui-nav-item layui-this' : 'layui-nav-item' }">
            <a href="/">首页</a>
        </li>
        <li th:class="${index == 1 ? 'layui-nav-item layui-this' : 'layui-nav-item' }">
            <a href="/articles">文章</a>
        </li>
        <li th:class="${index == 2 ? 'layui-nav-item layui-this' : 'layui-nav-item' }">
            <a href="/posts">帖子</a>
        </li>
        <li class="layui-nav-item">
            <a href="javascript:;">其它</a>
            <dl class="layui-nav-child">
                <dd>
                    <a href="">邮件管理</a>
                </dd>
                <dd>
                    <a href="">消息管理</a>
                </dd>
                <dd>
                    <a href="">授权管理</a>
                </dd>
            </dl>
        </li>
    </ul>
    <ul class="layui-nav layui-layout-right" th:if="${session.SPRING_SECURITY_CONTEXT != null }">
        <li class="layui-nav-item">
            <a href="javascript:;">
                <img src="http://via.placeholder.com/30x30" class="layui-nav-img">
                [[${session.SPRING_SECURITY_CONTEXT.authentication.principal.username }]]
            </a>
            <dl class="layui-nav-child">
                <dd>
                    <a href="/users/1">我的主页</a>
                </dd>
                <dd>
                    <a href="/user/1/setting">安全设置</a>
                </dd>
                <dd>
                    <a href="/admin/index">进入后台</a>
                </dd>
            </dl>
        </li>
        <li class="layui-nav-item">
            <a href="/logout">退出</a>
        </li>
    </ul>

    <ul class="layui-nav layui-layout-right" th:if="${session.SPRING_SECURITY_CONTEXT == null}">
        <li class="layui-nav-item">
            <a href="/login">登录</a>
        </li>
        <li class="layui-nav-item">
            <a href="/register">注册</a>
        </li>
    </ul>
</div>